﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Amoo.Code.Business
{

    public class PageBase : System.Web.UI.Page
    {

        protected string _EventTarget { get; set; }
        protected string _EventArgument { get; set; }

        protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["userSite"] == null)
                {
                    
                }
            }

            if (Request["__EVENTTARGET"] != null)
            {
                
                _EventTarget = Request["__EVENTTARGET"];
                _EventArgument = Request["__EVENTARGUMENT"];

            }


            base.OnLoad(e);
        }


        protected override void OnPreRenderComplete(EventArgs e)
        {

            base.GetPostBackClientEvent(new Control(), null);            
            base.OnPreRenderComplete(e);
        }

        protected void ShowWindowAlert(string pMessage)
        {
            ShowWindowAlert(pMessage, 1);
        }
        
        protected void ShowWindowAlert(string pMessage, int pType)
        {

            string strHtml = "";
       
            strHtml += "<div id='dvWindowAlert' style='background-color: #999999; position:absolute; top:0px; left:0px; width:100%; height:100%; filter:alpha(opacity=40);'>";
            strHtml += "    <div style='border: 2px solid #ccffcc; position:absolute; top:35%; left:30%;; background-color: #FFFFFF; width:500px; height:100px;  font-family: Arial, Helvetica, sans-serif; font-size: 17px; color: #000000;'>";
            strHtml += "        <div style='position:absolute; background-color:#ccffcc; width:100%; height:20px;'>";
            strHtml += "            <div style='position:absolute; left:95%'><img src='/Images/close.png' title='Fechar a janela' style='cursor:hand;' onclick='closeWindowAlert()'/></div>";
            strHtml += "        </div>";
            
            
            if (pType == 1)
            {
                strHtml += "        <div style='position:absolute; top:35%; left:10px'><img src='/Images/Erro.jpg' width='40px' height='40px'></div>";
            }

            if (pType == 2)
            {
                strHtml += "        <div style='position:absolute; top:35%; left:10px'><img src='/Images/check.png' width='40px' height='40px'></div>";
            }
            
            strHtml += "        <div style='position:absolute; top:25%; left:70px'>" + pMessage + "</div>";
            strHtml += "    </div>";
            strHtml += "<script language=javascript>";
            strHtml += "    function closeWindowAlert()";
            strHtml += "    {";
            strHtml += "        document.getElementById('dvWindowAlert').style.visibility='hidden';";
            strHtml += "    }";
            strHtml += "</script>";
            strHtml += "</div>";

            Page.RegisterStartupScript("WindowAlert", strHtml);        
        }

    }
}
